package com.ljc.dao;

import com.ljc.entity.PurchaseApply;
import com.ljc.vo.PurchaseApplySearByUser;
import com.ljc.vo.PurchaseApplySearchByAdmit;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Repository
@Mapper
public interface PurchaseApplyDao {
    int insert(PurchaseApply purchaseApply);
    List<PurchaseApply> searchByUser(PurchaseApplySearByUser search);
    @Select("select * from purchase_apply where id=#{id}")
    PurchaseApply findById(int id);
    List<PurchaseApply> searchByAdmit(PurchaseApplySearchByAdmit search);

    @Update("update purchase_apply set status=#{status} where id=#{purchaseApplyId}")
    void setStatus(int purchaseApplyId,int status);

    @Select("select count(*) from purchase_apply where user_id=#{userId} and status=3")
    int countByUserID(int userId);
}
